package com.christina.service.domain.travel.model;

import lombok.Data;
import lombok.Builder;
import java.time.LocalDateTime;
import java.util.List;

/**
 * 出行规划结果模型
 * 
 * @author Christina
 */
@Data
@Builder
public class TravelPlanResult {
    
    /**
     * 规划ID
     */
    private Long planId;
    
    /**
     * 用户ID
     */
    private Long userId;
    
    /**
     * 规划状态
     */
    private PlanStatus status;
    
    /**
     * 推荐路线列表
     */
    private List<TravelRoute> recommendedRoutes;
    
    /**
     * 最优路线
     */
    private TravelRoute bestRoute;
    
    /**
     * 规划摘要
     */
    private PlanSummary summary;
    
    /**
     * 智能建议
     */
    private List<String> suggestions;
    
    /**
     * 创建时间
     */
    private LocalDateTime createTime;
    
    /**
     * 规划状态
     */
    public enum PlanStatus {
        PLANNING("规划中"),
        COMPLETED("已完成"),
        FAILED("规划失败"),
        CANCELLED("已取消");
        
        private final String description;
        
        PlanStatus(String description) {
            this.description = description;
        }
        
        public String getDescription() {
            return description;
        }
    }
    
    /**
     * 出行路线
     */
    @Data
    @Builder
    public static class TravelRoute {
        private String routeId;
        private String description;
        private Integer totalDuration;
        private Double totalCost;
        private Integer comfortScore;
        private Integer recommendScore;
        private List<RouteSegment> segments;
        
        // 添加getter方法
        public List<RouteSegment> getRoutes() {
            return segments;
        }
        
        public Double getTotalCost() {
            return totalCost;
        }
        
        public Integer getTotalDuration() {
            return totalDuration;
        }
        
        public List<String> getRecommendations() {
            return segments != null ? 
                segments.stream().map(RouteSegment::getDetails).toList() : 
                java.util.Collections.emptyList();
        }
    }
    
    /**
     * 路线段
     */
    @Data
    @Builder
    public static class RouteSegment {
        private String transportMode;
        private String departureLocation;
        private String arrivalLocation;
        private LocalDateTime departureTime;
        private LocalDateTime arrivalTime;
        private Integer duration;
        private Double cost;
        private String details;
    }
    
    /**
     * 规划摘要
     */
    @Data
    @Builder
    public static class PlanSummary {
        private Integer shortestTime;
        private Double lowestCost;
        private Double averageCost;
        private Integer routeCount;
    }
}